package org.example.springbookdemo.service;

import org.example.springbookdemo.dao.BookDao;
import org.example.springbookdemo.model.BookInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: Themberfue
 * @date: 2025/1/23 11:13
 * @description:
 */
// ? 将该对象交给spring管理 (IoC，Inversion of Control)
@Service
public class BookService {
    // ? 从spring中获取该对象，并给属性赋值，前提是该对象已经被spring管理
    @Autowired
    BookDao bookDao;

    List<BookInfo> bookList;
    public List<BookInfo> getBookList() {
        bookList = bookDao.mockData();
        for (BookInfo bookInfo: bookList) {
            bookInfo.setStatusCN(bookInfo.getStatus() == 1 ? "可借阅" : "不可借阅");
        }
        return bookList;
    }
}
